import json
from GlobalValues import globalVal
from util import LiveRtmp
from serviceImpl import EquipmentFunctionServiceImpl


def openEquipmentFunction():
    try:
        print('方法开始')
        globalVal.bl_live = True
        globalVal.liveRTMP_future = globalVal.pool.submit(LiveRtmp.live)
        return '1'
    except Exception as e:
        print(e)
        return '0'


def closeEquipmentFunction():
    try:
        print('方法关闭')
        globalVal.bl_live = False
        return '1'
    except Exception as e:
        print(e)
        return '0'


def downEquipmentFunction(args):
    command = args['command']
    target = command['target']

    print(target)
    if target == 'GetParamNames':  # 获取修改参数的名称
        data = EquipmentFunctionServiceImpl.getParamNames()
        return data
    elif target == 'ModifyParams':  # 修改参数
        data = EquipmentFunctionServiceImpl.modifyParams(command)
        return data
    elif target == 'OpenPointCould':  # 开启点云
        data = EquipmentFunctionServiceImpl.openPointCould()
        return data
    elif target == 'closePointCould':  # 关闭点云
        data = EquipmentFunctionServiceImpl.closePointCould()
        return data
    elif target == 'GetFunctions':  # 获取功能控制页面
        data = EquipmentFunctionServiceImpl.closePointCould()
        return data
